<!DOCTYPE html>
<html lang="en">

<!--****头部 star****-->
@include('Admin.Public.header')

<body>
<div class="wrapper scrollbar-inner">
    <div class="main-panel">
        <div class="content" style="margin-top: 20px;">
            <div class="page-inner">
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item active" aria-current="page">系统设置</li>
                        <li class="breadcrumb-item"><a href="javascript:window.history.go(0);">基础设置</a></li>
                    </ol>
                </nav>

                <div class="row">

                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-header">
                                <div class="d-flex align-items-center">
                                    <h4 class="card-title">操作</h4>
                                    <button class="btn btn-primary btn-round ml-auto" data-toggle="modal"
                                            onclick="skipURL('/myadmin/config/add')"
                                            data-target="#addRowModal">
                                        <i class="fa fa-plus"></i>
                                        添加
                                    </button>
                                </div>
                            </div>

                            <div class="table-responsive">
                                <div id="add-row_wrapper" class="dataTables_wrapper container-fluid dt-bootstrap4"
                                     style="margin-top: 5px;">

                                    <div class="row">
                                        <div class="col-sm-12 col-md-9">
                                            @include('Admin.Public.paging_limit')
                                        </div>
                                        <div class="col-sm-12 col-md-3">
                                            <div id="add-row_filter" class="dataTables_filter">
                                                <form class="navbar-left navbar-form nav-search mr-md-3">
                                                    <div class="input-group" style="background: unset; height: 31px;">
                                                        <div class="input-group-prepend" style="height: 31px;">
                                                            <button type="submit" class="btn btn-search pr-1">
                                                                <i class="fa fa-search search-icon"></i>
                                                            </button>
                                                        </div>
                                                        <input type="text" placeholder="配置名, 主键" name="keywords"
                                                               class="form-control"
                                                               style="height: 31px; width: 75%; max-width: unset; min-width: unset;">
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <div class="col-sm-12">
                                            <table id="add-row"
                                                   class="display table table-striped table-hover dataTable"
                                                   role="grid" aria-describedby="add-row_info">
                                                <thead>
                                                <thead>
                                                <tr role="row">
                                                    <th class="sorting_asc" tabindex="0" aria-controls="add-row"
                                                        rowspan="1"
                                                        colspan="1" aria-sort="ascending"
                                                        aria-label="Name: activate to sort column descending"
                                                        style="width: 127px;">Id
                                                    </th>

                                                    <th class="sorting" tabindex="0" aria-controls="add-row" rowspan="1"
                                                        colspan="1"
                                                        aria-label="Position: activate to sort column ascending"
                                                        style="width: 193px;">配置名称
                                                    </th>

                                                    <th style="width: 108px;" class="sorting" tabindex="0"
                                                    aria-controls="add-row" rowspan="1" colspan="1"
                                                    aria-label="Action: activate to sort column ascending">配置主键
                                                    </th>

                                                    <th style="width: 108px;" class="sorting" tabindex="0"
                                                        aria-controls="add-row" rowspan="1" colspan="1"
                                                        aria-label="Action: activate to sort column ascending">配置内容
                                                    </th>

                                                    <th style="width: 108px;" class="sorting" tabindex="0"
                                                        aria-controls="add-row" rowspan="1" colspan="1"
                                                        aria-label="Action: activate to sort column ascending">添加时间
                                                    </th>

                                                    <th style="width: 108px;" class="sorting" tabindex="0"
                                                        aria-controls="add-row" rowspan="1" colspan="1"
                                                    >操作
                                                    </th>
                                                </tr>
                                                </thead>
                                                </thead>

                                                <tbody>
                                                @if($items->total() > 0)
                                                    @foreach ($items as $k => $item)
                                                        <tr role="row" class="odd">
                                                            <td class="sorting_1">{{$item['id']}}</td>
                                                            <td>{{$item['name']}}</td>
                                                            <td>{{$item['key']}}</td>
                                                            <td>{{$item['value']}}</td>
                                                            <td>{{$item['created_at']}}</td>
                                                            <td>
                                                                <div class="form-button-action">
                                                                        <button type="button" data-toggle="tooltip"
                                                                                title=""
                                                                                class="btn btn-link btn-primary btn-lg"
                                                                                data-original-title="修改"
                                                                                onclick="skipURL('/myadmin/config/edit', 'id={{$item['id']}}')">
                                                                            <i class="fas fa-edit"></i>
                                                                        </button>
                                                                        {{--<button type="button" data-toggle="tooltip"--}}
                                                                                {{--title=""--}}
                                                                                {{--class="btn btn-link btn-danger"--}}
                                                                                {{--data-original-title="删除"--}}
                                                                                {{--onclick="del({{$item['id']}})">--}}
                                                                            {{--<i class="fa fa-times"></i>--}}
                                                                        {{--</button>--}}
                                                                </div>
                                                            </td>
                                                        </tr>
                                                    @endforeach
                                                @endif

                                                </tbody>
                                            </table>
                                            @if($items->total() < 1)
                                                <div class="card-sub">
                                                    暂无内容
                                                </div>
                                            @endif
                                        </div>
                                    </div>

                                    <!-- 分页 -->
                                    {{  $items->links('Admin/Public/paging', ['keywords' => $keywords]) }}
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>

        </div>
    </div>
</div>

@include('Admin.Public.footer')


<script>
    /**
     * 更改状态
     * @param id
     * @param type
     */
    function changeStatus(id, type) {
        var hint = type == 1 ? '已处理' : '拒绝';
        swal({
            title: `确定${hint}吗?`,
            text: "此操作会影响客户使用请谨慎操作!",
            type: 'warning',
            buttons: {
                confirm: {
                    text: '确定',
                    className: 'btn btn-success'
                },
                cancel: {
                    text: '取消',
                    visible: true,
                    className: 'btn btn-danger'
                }
            }
        }).then((Delete) => {
            if (!Delete) {
                swal.close();
                return;
            }
            $.requestAjax({
                type: "post",
                url: "/myadmin/bills/withdraw/change_status_merchant",
                data: {"id": id, 'status': type},
                dataType: "json",
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                success: function (e) {
                    swal("成功!", e.msg, {
                        icon: "success",
                        buttons: {
                            confirm: {
                                className: 'btn btn-success'
                            }
                        },
                    }).then(function () {
                        window.history.go(0)
                    });
                },
                error: function (e) {

                }
            });
        });
    }


    /**
     * 删除
     * @param id
     */
    function del(id) {
        swal({
            title: `确定删除吗?`,
            text: "数据删除后不可恢复!",
            type: 'warning',
            buttons: {
                confirm: {
                    text: '确定',
                    className: 'btn btn-success'
                },
                cancel: {
                    text: '取消',
                    visible: true,
                    className: 'btn btn-danger'
                }
            }
        }).then((Delete) => {
            if (!Delete) {
                swal.close();
                return;
            }
            $.requestAjax({
                type: "post",
                url: "/myadmin/config/delete",
                data: {"id": id},
                dataType: "json",
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                success: function (e) {
                    swal("成功!", e.msg, {
                        icon: "success",
                        buttons: {
                            confirm: {
                                className: 'btn btn-success'
                            }
                        },
                    }).then(function () {
                        window.history.go(0)
                    });
                },
                error: function (e) {

                }
            });
        });
    }


</script>
</body>
</html>